<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // ES6允许给函数的参数赋默认初始值

        // 1. 形参初始值
        function sum(a, b, c = 0) {
            console.log(a, b, c)
        }
        sum(1, 3)

        // 2. 与结构赋值结合
        function post(params = {name: 'X', age: 18}) {
            console.log('params:', params);
        }
        post()

        function get({name = 'ES6', age}) {
            console.log('name:', name, ', age:', age);
        }
        get({
            age: 18,
            sex: '女'
        })

    </script>
</body>
</html>